package com.hibase.core.rule.utils.operator;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;

public class LengthOperator extends Operator {
    @Override
    public Object executeInner(Object[] list) throws Exception {
        Object param0 = list[0];
        if(ObjectUtil.isNull(param0)){
            throw new QLException("对象为null,不能执行list相关操作");
        }
        if(param0.getClass().isArray() == false){
            throw new QLException("对象不为数组,不能执行数组相关操作");
        }
        return ArrayUtil.cast(null,param0).length;
    }
}
